<?php if (!defined('THINK_PATH')) exit();?><!DOCTYPE html>
<html>
	<head>
		<meta name="viewport" content="width=750, user-scalable=no, target-densitydpi=device-dpi">
		<meta charset="utf-8">
		<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=">
		<title>登录</title> 

        <link rel="stylesheet" href="<?php echo C('WEB_URL');?>Public/dpi/css/style.css">

        <script src="<?php echo C('WEB_URL');?>Public/dpi/js/dpi.js"></script>
        <script src="<?php echo C('WEB_URL');?>Public/dpi/js/jquery-1.7.2.min.js"></script>
	</head>
<body>
		<div class="login">
			<center>	 <a href="#" class="login_title">商家登录</a>	</center>
			<div class="login_form">
				<form id="myForm" method="post">
                    <input type="text" value=""  name='tel' class="login_phone" maxlength="11"  id="tel" placeholder="请输入您的手机号"/>
	                    <div class="login_per">
		                    <input type="text"  id='yam' class="login_tel"  name='yam' value="" placeholder="请输入验证码"/>
		                    <a class="login_tel_a" id='btn'>发送验证码</a>
	                    </div>
                    <div class="login_form_img" ><img src="<?php echo C('WEB_URL');?>Public/dpi/image/qqk.png" width="100%"></div>
                    <a href="#" id="cun" class="login_form_butt">确认提交</a>
				</form>
			</div>		
		</div>			
</body>
</html>

<script>
	$('#btn').click(function(){
	var phone=$('#tel').val();
	var type=1;

	$.ajax({
		  type:'GET',
		  url:"<?php echo C('WEB_URL');?>home/Api/sendcode",
		  dataType: "json",
		  data:{"phone":phone,"type":type	},
		  success:function(data){		
		  	// console.log(data.data.desc );	
		  	$('#yam').val(data.data.desc);
		  	}	
})


})



	function check_form(form_id) {
				last_submit = $('#' + form_id).data('last_submit');
				current_submit = new Date().getTime();
				if (last_submit == undefined) {
					$('#' + form_id).data('last_submit', new Date().getTime());
				} else {
					if (current_submit - last_submit > 600) {
						$('#' + form_id).data('last_submit', new Date().getTime());
					} else {
						return false;
					}
				}
				if ( typeof (tinyMCE) != 'undefined') {
					tinyMCE.triggerSave(true);
				}

				var check_flag = true;
				$("#" + form_id + " :input").each(function(i) {
					if ($(this).attr("check")) {
						if (!validate($(this).val(), $(this).attr("check"))) {
							ui_error($(this).attr("msg"));
							$(this).focus();
							check_flag = false;
							return check_flag;
						}
					}
				});
				return check_flag;
			}


			function sendForm(formId, post_url, return_url) {
				if (check_form(formId)) {
					//绑定beforeunload事件
					$(window).unbind('beforeunload', null);
					if ($("#ajax").val() == 1) {
						var vars = $("#" + formId).serialize();
						$.ajax({
							type : "POST",
							url : post_url,
							data : vars,
							dataType : "json",
							success : function(data) {
								if (data.status) {
									ui_alert(data.info, function() {
										if (return_url) {
											location.href = return_url;
										}
									});
								} else {
									ui_error(data.info);
								}
							}
						});
					} else {
						$("#" + formId).attr("action", post_url);
						if (return_url) {
							set_cookie('return_url', return_url);
						}
						$("#" + formId).submit();
					}
				}
			}
			$('#cun').click(function(){
				sendForm("myForm","<?php echo U('Business/toLogin');?>");
			})
</script>